package com.gao.weblog.web.convert;

import com.gao.weblog.common.domain.dos.ArticleDO;
import com.gao.weblog.web.module.vo.archive.FindArchiveArticleRspVO;
import com.gao.weblog.web.module.vo.article.FindIndexArticlePageListRspVO;
import com.gao.weblog.web.module.vo.category.FindCategoryArticleListRspVO;
import com.gao.weblog.web.module.vo.tag.FindTagArticlePageListRspVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface ArticleConvert {

    ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class);

    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindIndexArticlePageListRspVO convertDO2VO(ArticleDO bean);

    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    @Mapping(target = "createMonth", expression = "java(java.time.YearMonth.from(bean.getCreateTime()))")
    FindArchiveArticleRspVO convertDO2ArchiveRspVO(ArticleDO bean);

    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindCategoryArticleListRspVO convertDO2CategoryArticleVO(ArticleDO bean);

    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindTagArticlePageListRspVO convertDO2TagArticleVO(ArticleDO bean);
}
